#!/bin/sh
#
# This is the script for generating files for a specific Dalton test job.
#
# For the .check file ksh or bash is preferred, otherwise use sh
# (and hope it is not the old Bourne shell, which will not work)
#
if [ -e /bin/ksh ]; then
   CHECK_SHELL='#!/bin/ksh'
elif [ -e /bin/bash ]; then
   CHECK_SHELL='#!/bin/bash'
else
   CHECK_SHELL='#!/bin/sh'
fi


#######################################################################
#  TEST DESCRIPTION
#######################################################################
cat << EODAL > rsp_g_rohf_ecc.dal
**DALTON INPUT
.RUN RESPONSE
.DIRECT
**WAVE FUNCTION
.HF
*SCF INPUT
**RESPONSE
*ESR
.G-TENSOR
.ECC
**END OF DALTON INPUT

EODAL
cat << EOMOL > rsp_g_rohf_ecc.mol
# DALTON.BAS with INTGRL directive created 30Mar05  10:29:24
# Directive in input mol file was:
# > ATOMBASIS                                                                   
INTGRL
Title1                                                                          
Title2                                                                          
    2  1 2X  Y        0.10E-14
        6.    1    3    1    1    1
C        0.0000000000000     0.0000000000000    -1.2039673896295
H  13    8
    35088.0000000000        0.0006700000        0.0000000000        0.0000000000
                            0.0000000000        0.0000000000        0.0000000000
                            0.0000000000        0.0000000000
     5257.4000000000        0.0052020000        0.0000000000        0.0000000000
                            0.0000000000        0.0000000000        0.0000000000
                            0.0000000000        0.0000000000
     1196.5000000000        0.0272070000        0.0000000000        0.0000000000
                            0.0000000000        0.0000000000        0.0000000000
                            0.0000000000        0.0000000000
      338.8400000000        0.1127590000        0.0000000000        0.0000000000
                            0.0000000000        0.0000000000        0.0000000000
                            0.0000000000        0.0000000000
      110.4800000000        0.3877040000        0.0000000000        0.0000000000
                            0.0000000000        0.0000000000        0.0000000000
                            0.0000000000        0.0000000000
       39.7850000000        0.5656540000        0.1880920000        0.0000000000
                            0.0000000000        0.0000000000        0.0000000000
                            0.0000000000        0.0000000000
       15.3660000000        0.0000000000        0.8353530000        0.0000000000
                            0.0000000000        0.0000000000        0.0000000000
                            0.0000000000        0.0000000000
        6.2406000000        0.0000000000        0.0000000000        1.0000000000
                            0.0000000000        0.0000000000        0.0000000000
                            0.0000000000        0.0000000000
        2.5893000000        0.0000000000        0.0000000000        0.0000000000
                            1.0000000000        0.0000000000        0.0000000000
                            0.0000000000        0.0000000000
        0.7410500000        0.0000000000        0.0000000000        0.0000000000
                            0.0000000000        1.0000000000        0.0000000000
                            0.0000000000        0.0000000000
        0.2933400000        0.0000000000        0.0000000000        0.0000000000
                            0.0000000000        0.0000000000        1.0000000000
                            0.0000000000        0.0000000000
        0.1118700000        0.0000000000        0.0000000000        0.0000000000
                            0.0000000000        0.0000000000        0.0000000000
                            1.0000000000        0.0000000000
        0.0500000000        0.0000000000        0.0000000000        0.0000000000
                            0.0000000000        0.0000000000        0.0000000000
                            0.0000000000        1.0000000000
H   9    6
       61.6360000000        0.0082440000        0.0000000000        0.0000000000
                            0.0000000000        0.0000000000        0.0000000000
       14.4440000000        0.0602880000        0.0000000000        0.0000000000
                            0.0000000000        0.0000000000        0.0000000000
        4.4412000000        0.2584790000        0.0000000000        0.0000000000
                            0.0000000000        0.0000000000        0.0000000000
        1.5716000000        0.7702260000        0.0000000000        0.0000000000
                            0.0000000000        0.0000000000        0.0000000000
        0.5980400000        0.0000000000        1.0000000000        0.0000000000
                            0.0000000000        0.0000000000        0.0000000000
        0.2301900000        0.0000000000        0.0000000000        1.0000000000
                            0.0000000000        0.0000000000        0.0000000000
        0.0865960000        0.0000000000        0.0000000000        0.0000000000
                            1.0000000000        0.0000000000        0.0000000000
        0.0300000000        0.0000000000        0.0000000000        0.0000000000
                            0.0000000000        1.0000000000        0.0000000000
        0.0050000000        0.0000000000        0.0000000000        0.0000000000
                            0.0000000000        0.0000000000        1.0000000000
H   3    3
        0.9000000000        1.0000000000        0.0000000000        0.0000000000
        0.1300000000        0.0000000000        1.0000000000        0.0000000000
        0.0200000000        0.0000000000        0.0000000000        1.0000000000
        8.    1    3    1    1    1
O        0.0000000000000     0.0000000000000     0.9032626103705
H  13    8
    63655.0000000000        0.0006590000        0.0000000000        0.0000000000
                            0.0000000000        0.0000000000        0.0000000000
                            0.0000000000        0.0000000000
     9537.6000000000        0.0051150000        0.0000000000        0.0000000000
                            0.0000000000        0.0000000000        0.0000000000
                            0.0000000000        0.0000000000
     2170.7000000000        0.0267620000        0.0000000000        0.0000000000
                            0.0000000000        0.0000000000        0.0000000000
                            0.0000000000        0.0000000000
      614.7200000000        0.1110120000        0.0000000000        0.0000000000
                            0.0000000000        0.0000000000        0.0000000000
                            0.0000000000        0.0000000000
      200.4500000000        0.3827710000        0.0000000000        0.0000000000
                            0.0000000000        0.0000000000        0.0000000000
                            0.0000000000        0.0000000000
       72.2300000000        0.5720990000        0.1839650000        0.0000000000
                            0.0000000000        0.0000000000        0.0000000000
                            0.0000000000        0.0000000000
       27.9720000000        0.0000000000        0.8389550000        0.0000000000
                            0.0000000000        0.0000000000        0.0000000000
                            0.0000000000        0.0000000000
       11.4230000000        0.0000000000        0.0000000000        1.0000000000
                            0.0000000000        0.0000000000        0.0000000000
                            0.0000000000        0.0000000000
        4.7730000000        0.0000000000        0.0000000000        0.0000000000
                            1.0000000000        0.0000000000        0.0000000000
                            0.0000000000        0.0000000000
        1.4400000000        0.0000000000        0.0000000000        0.0000000000
                            0.0000000000        1.0000000000        0.0000000000
                            0.0000000000        0.0000000000
        0.5598400000        0.0000000000        0.0000000000        0.0000000000
                            0.0000000000        0.0000000000        1.0000000000
                            0.0000000000        0.0000000000
        0.2080700000        0.0000000000        0.0000000000        0.0000000000
                            0.0000000000        0.0000000000        0.0000000000
                            1.0000000000        0.0000000000
        0.0600000000        0.0000000000        0.0000000000        0.0000000000
                            0.0000000000        0.0000000000        0.0000000000
                            0.0000000000        1.0000000000
H   9    6
      111.5400000000        0.0083250000        0.0000000000        0.0000000000
                            0.0000000000        0.0000000000        0.0000000000
       26.2060000000        0.0623000000        0.0000000000        0.0000000000
                            0.0000000000        0.0000000000        0.0000000000
        8.1556000000        0.2696980000        0.0000000000        0.0000000000
                            0.0000000000        0.0000000000        0.0000000000
        2.9196000000        0.7578950000        0.0000000000        0.0000000000
                            0.0000000000        0.0000000000        0.0000000000
        1.1047000000        0.0000000000        1.0000000000        0.0000000000
                            0.0000000000        0.0000000000        0.0000000000
        0.4136800000        0.0000000000        0.0000000000        1.0000000000
                            0.0000000000        0.0000000000        0.0000000000
        0.1481000000        0.0000000000        0.0000000000        0.0000000000
                            1.0000000000        0.0000000000        0.0000000000
        0.0500000000        0.0000000000        0.0000000000        0.0000000000
                            0.0000000000        1.0000000000        0.0000000000
        0.0070000000        0.0000000000        0.0000000000        0.0000000000
                            0.0000000000        0.0000000000        1.0000000000
H   3    3
        0.9000000000        1.0000000000        0.0000000000        0.0000000000
        0.1300000000        0.0000000000        1.0000000000        0.0000000000
        0.0200000000        0.0000000000        0.0000000000        1.0000000000
EOMOL
cat << 'EOCHK' > rsp_g_rohf_ecc.check
log=$1
GREP=egrep

# ?
CRIT1=`$GREP "\@G * _\|_ * \|\|" $log | wc -l`
CRIT2=`$GREP "\@G RMC * \-192\. * \-192\." $log | wc -l`
CRIT3=`$GREP "\@G GC1 * 198\. * 92\." $log | wc -l`
CRIT4=`$GREP "\@G GC2 * \-113\. * \-76\." $log | wc -l`
CRIT5=`$GREP "\@G OZ\-SO1 \-1897\. * 0\." $log | wc -l`
CRIT6=`$GREP "\@G OZ\-SO2 * 747\. * 0\." $log | wc -l`
CRIT7=`$GREP "\@G Total * \-1257\. * \-176\." $log | wc -l`
TEST[1]=`expr	$CRIT1 \+ $CRIT2 \+ $CRIT3 \+ $CRIT4 \+ $CRIT5 \+ $CRIT6 \+ \
		$CRIT7`
CTRL[1]=7
ERROR[1]="G-shift components NOT CORRECT"
str="1"
PASSED=1
for i in $str
do
   if [ ${TEST[i]} -ne ${CTRL[i]} ]; then
     echo "${ERROR[i]} ( test = ${TEST[i]}; control = ${CTRL[i]} ); "
     PASSED=0
   fi
done

if [ $PASSED -eq 1 ]
then
  echo TEST ENDED PROPERLY
  exit 0
else
  echo THERE IS A PROBLEM
  exit 1
fi
EOCHK
